﻿using System; 
using System.Text;
using System.Collections.Generic; 
using System.Data;
using XQ.SP.Model;

namespace XQ.SP.BllServices{
	 	//产品详细复制国美
		public partial class ShopProduceCopyGuoBLL : BaseBll
	{
   		     
		private readonly XQ.SP.DalServices.ShopProduceCopyGuoDal dal=new XQ.SP.DalServices.ShopProduceCopyGuoDal();
		public ShopProduceCopyGuoBLL()
		{}
		
		#region  Method
		/// <summary>
		/// 是否存在该记录
		/// </summary>
		public bool ExistsWhere(string whereSql)
		{
			return dal.ExistsWhere(whereSql);
		}
		
		/// <summary>
		/// 是否存在该记录
		/// </summary>
		public bool Exists(long Id)
		{
			return dal.Exists(Id);
		}

		
		/// <summary>
		/// 增加一条数据
		/// </summary>
		public long  Add(XQ.SP.Model.ShopProduceCopyGuoItem model)
		{
			return dal.Add(model);	
		}

		/// <summary>
		/// 批量增加数据
		/// </summary>
		public bool  AddList(List<XQ.SP.Model.ShopProduceCopyGuoItem> models)
		{
            int rows=dal.AddList(models);
            if (rows > 0)
                return true;
            else
                return false;
		}


		/// <summary>
		/// 更新一条数据
		/// </summary>
		public bool Update(XQ.SP.Model.ShopProduceCopyGuoItem model)
		{
			return dal.Update(model);
		}

		/// <summary>
		/// 批量更新数据
		/// </summary>
		public int UpdateList(List<XQ.SP.Model.ShopProduceCopyGuoItem> models)
		{
			return dal.UpdateList(models);
		}

		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool Delete(long Id)
		{
			
			return dal.Delete(Id);
		}
				/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool DeleteList(string Idlist )
		{
			return dal.DeleteList(Idlist );
		}
		
		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public XQ.SP.Model.ShopProduceCopyGuoItem GetModel(long Id)
		{
			
			return dal.GetModel(Id);
		}
		
		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public XQ.SP.Model.ShopProduceCopyGuoItem GetModelWhereStr(string whereSql)
		{
			
			return dal.GetModelWhereStr(whereSql);
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetList(string strWhere="")
		{
			return dal.GetList(strWhere);
		}
		/// <summary>
		/// 获得前几行数据
		/// </summary>
		public DataSet GetList(int Top,string strWhere,string filedOrder)
		{
			return dal.GetList(Top,strWhere,filedOrder);
		}
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<XQ.SP.Model.ShopProduceCopyGuoItem> GetModelList(string strWhere="")
		{
			DataSet ds = dal.GetList(strWhere);
			return DataTableToList(ds.Tables[0]);
		}
		
        /// <summary>
        /// 获得新增的数据
        /// </summary>
        public List<XQ.SP.Model.ShopProduceCopyGuoItem> GetModelListNew(string datetimeStr)
        {
            DataSet ds = dal.GetList(" Created>='"+datetimeStr+"' ");
            return DataTableToList(ds.Tables[0]);
        }
        
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<XQ.SP.Model.ShopProduceCopyGuoItem> DataTableToList(DataTable dt)
		{
			List<XQ.SP.Model.ShopProduceCopyGuoItem> modelList = new List<XQ.SP.Model.ShopProduceCopyGuoItem>();
			int rowsCount = dt.Rows.Count;
			if (rowsCount > 0)
			{
				XQ.SP.Model.ShopProduceCopyGuoItem model;
				for (int n = 0; n < rowsCount; n++)
				{
					model = new XQ.SP.Model.ShopProduceCopyGuoItem();					
													if(dt.Rows[n]["Id"].ToString()!="")
				{
					model.Id=long.Parse(dt.Rows[n]["Id"].ToString());
				}
																																				model.ProduceNO= dt.Rows[n]["ProduceNO"].ToString();
																																model.ShopProduceName= dt.Rows[n]["ShopProduceName"].ToString();
																												if(dt.Rows[n]["PriceWai"].ToString()!="")
				{
					model.PriceWai=decimal.Parse(dt.Rows[n]["PriceWai"].ToString());
				}
																																if(dt.Rows[n]["PriceNei"].ToString()!="")
				{
					model.PriceNei=decimal.Parse(dt.Rows[n]["PriceNei"].ToString());
				}
																																if(dt.Rows[n]["PriceMin"].ToString()!="")
				{
					model.PriceMin=decimal.Parse(dt.Rows[n]["PriceMin"].ToString());
				}
																																if(dt.Rows[n]["NumberMin"].ToString()!="")
				{
					model.NumberMin=int.Parse(dt.Rows[n]["NumberMin"].ToString());
				}
																																if(dt.Rows[n]["SellsNumber"].ToString()!="")
				{
					model.SellsNumber=int.Parse(dt.Rows[n]["SellsNumber"].ToString());
				}
																																				model.Unit= dt.Rows[n]["Unit"].ToString();
																																model.ShopUsersName= dt.Rows[n]["ShopUsersName"].ToString();
																												if(dt.Rows[n]["Transactions"].ToString()!="")
				{
					model.Transactions=int.Parse(dt.Rows[n]["Transactions"].ToString());
				}
																																				model.Address= dt.Rows[n]["Address"].ToString();
																																model.Contact= dt.Rows[n]["Contact"].ToString();
																																model.Description= dt.Rows[n]["Description"].ToString();
																												if(dt.Rows[n]["ShopBrandId"].ToString()!="")
				{
					model.ShopBrandId=long.Parse(dt.Rows[n]["ShopBrandId"].ToString());
				}
																																if(dt.Rows[n]["ShopTypeID"].ToString()!="")
				{
					model.ShopTypeID=long.Parse(dt.Rows[n]["ShopTypeID"].ToString());
				}
																																if(dt.Rows[n]["StoreBaseID"].ToString()!="")
				{
					model.StoreBaseID=long.Parse(dt.Rows[n]["StoreBaseID"].ToString());
				}
																																				model.StoreBaseName= dt.Rows[n]["StoreBaseName"].ToString();
																												if(dt.Rows[n]["InsertDateTime"].ToString()!="")
				{
					model.InsertDateTime=DateTime.Parse(dt.Rows[n]["InsertDateTime"].ToString());
				}
																																if(dt.Rows[n]["UpdateDateTime"].ToString()!="")
				{
					model.UpdateDateTime=DateTime.Parse(dt.Rows[n]["UpdateDateTime"].ToString());
				}
																																if(dt.Rows[n]["StartDateTime"].ToString()!="")
				{
					model.StartDateTime=DateTime.Parse(dt.Rows[n]["StartDateTime"].ToString());
				}
																																if(dt.Rows[n]["LimitDays"].ToString()!="")
				{
					model.LimitDays=int.Parse(dt.Rows[n]["LimitDays"].ToString());
				}
																																if(dt.Rows[n]["UserID"].ToString()!="")
				{
					model.UserID=long.Parse(dt.Rows[n]["UserID"].ToString());
				}
																																				model.UserName= dt.Rows[n]["UserName"].ToString();
																																model.ImagesPhoto= dt.Rows[n]["ImagesPhoto"].ToString();
																																model.ImagesSP= dt.Rows[n]["ImagesSP"].ToString();
																												if(dt.Rows[n]["IsHave"].ToString()!="")
				{
					model.IsHave=int.Parse(dt.Rows[n]["IsHave"].ToString());
				}
																																if(dt.Rows[n]["ClickCount"].ToString()!="")
				{
					model.ClickCount=int.Parse(dt.Rows[n]["ClickCount"].ToString());
				}
																																if(dt.Rows[n]["State"].ToString()!="")
				{
					model.State=int.Parse(dt.Rows[n]["State"].ToString());
				}
																																if(dt.Rows[n]["Status"].ToString()!="")
				{
					model.Status=int.Parse(dt.Rows[n]["Status"].ToString());
				}
																																if(dt.Rows[n]["Creator"].ToString()!="")
				{
					model.Creator=long.Parse(dt.Rows[n]["Creator"].ToString());
				}
																																if(dt.Rows[n]["Created"].ToString()!="")
				{
					model.Created=DateTime.Parse(dt.Rows[n]["Created"].ToString());
				}
																																if(dt.Rows[n]["Modifier"].ToString()!="")
				{
					model.Modifier=long.Parse(dt.Rows[n]["Modifier"].ToString());
				}
																																if(dt.Rows[n]["Modified"].ToString()!="")
				{
					model.Modified=DateTime.Parse(dt.Rows[n]["Modified"].ToString());
				}
																																				model.ImagesSPAttr= dt.Rows[n]["ImagesSPAttr"].ToString();
																						
				
					modelList.Add(model);
				}
			}
			return modelList;
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetAllList()
		{
			return GetList("");
		}
		

   
		/// <summary>
		/// Model的属性对应赋值
		/// </summary>
		public void ModelCopy(XQ.SP.Model.ShopProduceCopyGuoItem modelOld,XQ.SP.Model.ShopProduceCopyGuoItem modelNew)
		{
			            
            modelNew.Id = modelOld.Id;
                        
            modelNew.ProduceNO = modelOld.ProduceNO;
                        
            modelNew.ShopProduceName = modelOld.ShopProduceName;
                        
            modelNew.PriceWai = modelOld.PriceWai;
                        
            modelNew.PriceNei = modelOld.PriceNei;
                        
            modelNew.PriceMin = modelOld.PriceMin;
                        
            modelNew.NumberMin = modelOld.NumberMin;
                        
            modelNew.SellsNumber = modelOld.SellsNumber;
                        
            modelNew.Unit = modelOld.Unit;
                        
            modelNew.ShopUsersName = modelOld.ShopUsersName;
                        
            modelNew.Transactions = modelOld.Transactions;
                        
            modelNew.Address = modelOld.Address;
                        
            modelNew.Contact = modelOld.Contact;
                        
            modelNew.Description = modelOld.Description;
                        
            modelNew.ShopBrandId = modelOld.ShopBrandId;
                        
            modelNew.ShopTypeID = modelOld.ShopTypeID;
                        
            modelNew.StoreBaseID = modelOld.StoreBaseID;
                        
            modelNew.StoreBaseName = modelOld.StoreBaseName;
                        
            modelNew.InsertDateTime = modelOld.InsertDateTime;
                        
            modelNew.UpdateDateTime = modelOld.UpdateDateTime;
                        
            modelNew.StartDateTime = modelOld.StartDateTime;
                        
            modelNew.LimitDays = modelOld.LimitDays;
                        
            modelNew.UserID = modelOld.UserID;
                        
            modelNew.UserName = modelOld.UserName;
                        
            modelNew.ImagesPhoto = modelOld.ImagesPhoto;
                        
            modelNew.ImagesSP = modelOld.ImagesSP;
                        
            modelNew.IsHave = modelOld.IsHave;
                        
            modelNew.ClickCount = modelOld.ClickCount;
                        
            modelNew.State = modelOld.State;
                        
            modelNew.Status = modelOld.Status;
                        
            modelNew.Creator = modelOld.Creator;
                        
            modelNew.Created = modelOld.Created;
                        
            modelNew.Modifier = modelOld.Modifier;
                        
            modelNew.Modified = modelOld.Modified;
                        
            modelNew.ImagesSPAttr = modelOld.ImagesSPAttr;
            		}
#endregion
   
	}
}